unit ServerContainerUnit1;

interface

uses System.SysUtils, System.Classes,
  Datasnap.DSTCPServerTransport,
  Datasnap.DSHTTPCommon, Datasnap.DSHTTP,
  Datasnap.DSServer, Datasnap.DSCommonServer,
  Datasnap.DSAuth, IPPeerServer,IdTCPConnection;

type
  TServerContainer1 = class(TDataModule)
    DSServer1: TDSServer;
    DSTCPServerTransport1: TDSTCPServerTransport;
    DSHTTPService1: TDSHTTPService;
    DSServerClass1: TDSServerClass;
    procedure DSServerClass1GetClass(DSServerClass: TDSServerClass;
      var PersistentClass: TPersistentClass);
    procedure DSServer1Connect(DSConnectEventObject: TDSConnectEventObject);
    //procedure ShowClientConnections(DSConnectEventObject: TDSConnectEventObject);
  private
    { Private declarations }
  public
    testIP : String;
  end;

var
  ServerContainer1: TServerContainer1;

implementation

uses Winapi.Windows, ServerMethodsUnit1,Unit1;

{$R *.dfm}

procedure TServerContainer1.DSServer1Connect(
  DSConnectEventObject: TDSConnectEventObject);
begin
  testIP := DSConnectEventObject.ChannelInfo.ClientInfo.IpAddress;
  Unit1.Form1.Memo1.Text := testIP;
  //ShowClientConnections(DSConnectEventObject);
end;

procedure TServerContainer1.DSServerClass1GetClass(
  DSServerClass: TDSServerClass; var PersistentClass: TPersistentClass);
begin
  PersistentClass := ServerMethodsUnit1.TServerMethods1;
  //testIp := '123456';
end;

//procedure TServerContainer1.ShowClientConnections(DSConnectEventObject: TDSConnectEventObject);
//var
//sb: TStringBuilder;
//begin
//   sb := TStringBuilder.Create;
//   try
//    sb.Append('IpAddress : ' + DSConnectEventObject.ChannelInfo.ClientInfo.IpAddress);
//    testIP := DSConnectEventObject.ChannelInfo.ClientInfo.IpAddress;
//    // Form1.edit1.Text:=  DSConnectEventObject.ChannelInfo.ClientInfo.IpAddress;
//   finally
//       sb.Free
//   end;
//end;


end.

